package com.wdc.deliveryrobot.fragment;

import android.content.Context;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.sirui.selfstudysdk.main.SelfChassisState;
import com.wdc.deliveryrobot.R;
import com.wdc.deliveryrobot.activity.BaseActivity;

public class VersionSettingFragment extends Fragment {

    private TextView textViewOne,textViewTwo,textViewThree,textViewFour;

    private Button buttonOpen,buttonExit;

    private SelfChassisState selfChassisState;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // 加载 Fragment 的布局
        View view = inflater.inflate(R.layout.fragment_version_setting, container, false);

        init(view);
        return view;
    }

    public void init(View view){
        textViewOne = view.findViewById(R.id.device_text_one);
        textViewTwo = view.findViewById(R.id.device_text_two);
        textViewThree = view.findViewById(R.id.device_text_three);
        textViewFour = view.findViewById(R.id.device_text_four);
        buttonOpen = view.findViewById(R.id.device_button);
        buttonExit = view.findViewById(R.id.exit);

        textViewTwo.setText(selfChassisState.getRobtId());
        buttonOpen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getContext(),"打开远程", Toast.LENGTH_SHORT).show();
            }
        });

        buttonExit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getContext(),"退出app", Toast.LENGTH_SHORT).show();
            }
        });
    }

//    public void setData(String dataTwo){
//        textViewOne.setText(dataOne);
//        textViewTwo.setText(dataTwo);
//        textViewThree.setText(dataThree);
//        textViewFour.setText(dataFour);
//    }

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        if (context instanceof BaseActivity) {
            selfChassisState = ((BaseActivity) context).selfChassisState;
        }
    }

}